<?php
###############   COPYLEFT GPLv3 LICENSE   ###############
##
## JFX Version 0.2.7
## Website Management Software
## www.jfxcms.com
##
## Copyright 2009 GPLv3 - http://www.opensource.org/licenses/gpl-3.0.html
##
## Anthony Gallon
## oi_antz@hotmail.com
##
## Permission is hereby granted to any person having a copy of this software
## to freely use and modify as required so long as the copyright notices
## and branding remain intact.
##
## Full license details available at http://www.jfxcms.com/license
##
###############   COPYLEFT GPLv3 LICENSE   ###############

if(count($_POST)>0){
    $error = false;

    $name = $_POST['name'];
    $user = $_POST['user'];
    $pass = $_POST['pass'];
    $host = $_POST['host'];
    $prefix = $_POST['prefix'];

    if(!@mysql_connect($host, $user, $pass)){
        $errors[] = 'Could not connect to host';
        $error = true;
    }elseif(!@mysql_select_db($name)){
        if(!mysql_query('CREATE DATABASE '.$name)){
            $errors[] = 'Could not select db';
            $error = true;
        }
    }

    if(!$error){
        $_SESSION['install']['database'] = array(
            'name' => $name,
            'user' => $user,
            'pass' => $pass,
            'host' => $host,
            'prefix' => $prefix
        );

        redirect('?step=paths');
    }

}



?>
<form method="post">
    <div class="form-field">
        <label>Database Host</label>
        <input type="text" name="host" value="<?php echo post('host', 'localhost') ?>" />
    </div>
    <div class="form-field">
        <label>Database User</label>
        <input type="text" name="user" value="<?php echo post('user', 'root') ?>" />
    </div>
    <div class="form-field">
        <label>Database Password</label>
        <input type="password" name="pass" value="<?php echo post('pass', '') ?>" />
    </div>
    <div class="form-field">
        <label>Database Name</label>
        <input type="text" name="name" value="<?php echo post('name', 'jfx') ?>" />
    </div>
    <div class="form-field">
        <label>Database Prefix</label>
        <input type="text" name="prefix" value="<?php echo post('prefix', 'jfx_') ?>" />
    </div>
    <div class="form-field">
        <label>&nbsp;</label>
        <input type="submit" name="submit" value="Proceed" />
    </div>

</form>








